package com.feng.zhihao.apigeteway.controller.interfaces;

import java.sql.SQLException;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feng.zhihao.apigeteway.controller.BaseController;
import com.feng.zhihao.apigeteway.dao.interfaces.ModularInfoDao;
import com.feng.zhihao.apigeteway.page.RestData;
import com.feng.zhihao.apigeteway.util.DBUtil;
import com.feng.zhihao.apigeteway.util.SQLUtil;
import com.xiaoleilu.hutool.log.LogFactory;

@RestController
@RequestMapping("/modular")
public class ModularInfoController extends BaseController{
	com.xiaoleilu.hutool.log.Log logger = LogFactory.get();
	
	@Autowired
	ModularInfoDao modularInfoDao;
	
	@RequestMapping("getProjectModular.do")
	public RestData getProjectModular(@RequestParam("page")int page,@RequestParam("size")int size,@RequestParam("projectId")String projectId,@RequestParam(value="modularId",required=false)String modularId) throws SQLException{
		String channel=getCurrentUser().getChannelInfo().getChannelId();
		if(StringUtils.isBlank(modularId)){
			return new RestData(DBUtil.page(SQLUtil.getSELECT_CHANNEL_PROJECT_MODULAR_LIST(), page, size,
					projectId,projectId,channel,projectId,channel,projectId,projectId));
		}else{
			return new RestData(DBUtil.page(SQLUtil.getSELECT_CHANNEL_PROJECT_MODULAR_MODULAR_LIST(), page, size,
					projectId,projectId,channel,projectId,channel,projectId,projectId,modularId));
		}
	}
	
}
